package com.freemalll.merchant.service.impl;

import com.freemalll.common.core.exception.BusinessException;
import com.freemalll.merchant.common.CommonEnum;
import com.freemalll.merchant.domain.dto.home.MerchantHomeDto;
import com.freemalll.merchant.domain.vo.home.HomeTodoCountVo;
import com.freemalll.merchant.domain.vo.home.MerchantHomeVo;
import com.freemalll.merchant.domain.vo.home.HomeToDoVo;
import com.freemalll.merchant.mapper.HomerMapper;
import com.freemalll.merchant.service.HomeService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author songshixiong
 * @ClassName HomeServiceImpl
 * @description:
 * @date 2025年06月17日
 * @version: 1.0
 */
@Slf4j
@Service
public class HomeServiceImpl implements HomeService {

    @Resource
    private HomerMapper homerMapper;

    @Override
    public List<MerchantHomeVo> list(MerchantHomeDto dto) {
        CommonEnum.homeQueryType homeQueryType = CommonEnum.homeQueryType.getByCode(dto.getQueryType());
        if (homeQueryType == null) {
            throw BusinessException.businessValidateError("查询类型错误");
        }
        switch (homeQueryType) {
            case REVIEW_NEW_ACCOUNT:
            case SEARCH_REPORT:
                return homerMapper.list(dto);
            case CHANGE_INFO:
                log.warn("---------- 没写 ----------");
                return null;
            case ALLOCATION_RATE:
                log.warn("---------- 算了 ----------");
                return null;
            case SALARY_ADJUSTMENT_PARTY:
                log.warn("---------- 下次一定 ----------");
                return null;
            case CHECK_MONITORING:
                log.warn("---------- 下下次一定 ----------");
                return null;
            case CHANGE_STATUS:
                log.warn("---------- 下下下次一定 ----------");
                return null;
            default:
                throw BusinessException.businessValidateError("查询类型错误");
        }
    }

    @Override
    public List<HomeToDoVo> alreadyDoneList() {
        //查复审通过、复审拒绝、复审取消的
        //只查5条
        return homerMapper.alreadyDoneList();
    }

    @Override
    public List<HomeToDoVo> needToBeDealtWithList() {
        //只查5条待审核的
        return homerMapper.needToBeDealtWithList();
    }

    @Override
    public HomeTodoCountVo needToBeDealtWithListCount() {
        int todoListCount = homerMapper.queryTodoListCount();
        HomeTodoCountVo homeTodoCountVo = new HomeTodoCountVo();
        homeTodoCountVo.setNumberOfCollaborativeReviews(todoListCount);
        return homeTodoCountVo;
    }

    @Override
    public HomeTodoCountVo alreadyDoneListCount() {
        int alreadyDoneCount = homerMapper.queryAlreadyDoneCount();
        HomeTodoCountVo homeTodoCountVo = new HomeTodoCountVo();
        homeTodoCountVo.setNumberOfActivityApprovals(alreadyDoneCount);
        return homeTodoCountVo;
    }


}
